/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.scm.rmpm.pojo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import merlion.scm.rmpm.entity.RawMaterial;
import merlion.scm.rmpm.entity.RawMaterialSupplyInformation;
import merlion.scm.rmpm.entity.Supplier;

/**
 *
 * @author Kenn
 */
public class SupplierListRow implements Serializable {
    
    private Supplier supplier;
    private ArrayList<RawMaterial> materials;
    private List<Boolean> materialSupplied;
    private ArrayList<String> acronyms;
    private ArrayList<Long> purchases;
    
    public SupplierListRow(Supplier supplier, ArrayList<RawMaterial> objects){
        this.supplier = supplier;
        materials = objects;
        materialSupplied = new ArrayList<Boolean>();
        acronyms = new ArrayList<String>();
        purchases = new ArrayList<Long>();
        setList();
    }
    
    private void setList(){
        for(RawMaterial rm: materials){
            boolean found = false;
            for(RawMaterialSupplyInformation rmsi: supplier.getRawMaterialsSupplied()){
                if(rm.getName().equals(rmsi.getRawMaterial().getName()))
                    found = true;
            }
            materialSupplied.add(found);
            acronyms.add(rm.getAcronym());
            purchases.add(0L);
        }
    }
    
    private void print(){
        for(int i = 0; i < materials.size(); i++){
            System.out.println(acronyms.get(i));
        }
    }

    public List<Boolean> getMaterialSupplied() {
        return materialSupplied;
    }

    public void setMaterialSupplied(List<Boolean> materialSupplied) {
        this.materialSupplied = materialSupplied;
    }

    public Supplier getSupplier() {
        return supplier;
    }

    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    public ArrayList<String> getAcronyms() {
        return acronyms;
    }

    public void setAcronyms(ArrayList<String> acronyms) {
        this.acronyms = acronyms;
    }

    public ArrayList<RawMaterial> getMaterials() {
        return materials;
    }

    public void setMaterials(ArrayList<RawMaterial> materials) {
        this.materials = materials;
    }

    public ArrayList<Long> getPurchases() {
        return purchases;
    }

    public void setPurchases(ArrayList<Long> purchases) {
        this.purchases = purchases;
    }
    
    @Override
    public SupplierListRow clone(){
        SupplierListRow s = new SupplierListRow(supplier, materials);
        s.setAcronyms(acronyms);
        s.setMaterialSupplied(materialSupplied);
        s.setPurchases(new ArrayList<Long>());
        for(Long purchase: purchases){
            s.getPurchases().add((Long)purchase.longValue());
        }
        return s;
    }
}
